package com.bestom.t9mod.base.service;

import com.bestom.t9mod.base.service.Interface.IObser.Observer;
import com.bestom.t9mod.commons.listener.DataReceivedListener;

import java.lang.ref.SoftReference;


/**
 * 观察者，接收串口数据 通知服务
 */
public class SerialObserver implements Observer {

//    private SoftReference<DataReceivedListener> mDataReceivedListenerSoftReference;

    private DataReceivedListener dataReceivedListener;

    /**
     * 对数据观察者设置监听
     * @param dataReceivedListener 监听
     */
    public void setOnDataReceivedListener(DataReceivedListener dataReceivedListener){
        this.dataReceivedListener=dataReceivedListener;
//        mDataReceivedListenerSoftReference = new SoftReference<DataReceivedListener>(dataReceivedListener);
    }

    @Override
    public void dataReceived(String dataHex) {
        dataReceivedListener.data(dataHex);
//        mDataReceivedListenerSoftReference.get().data(dataHex);
    }
}
